# -*- coding: utf-8 -*-
# @project: huawang-api20230914
# @file： tmp_lg-03.py
# @Time：2023/8/16 17:14
# @Author：liaogan
from idlelib import window

import document as document
from selenium import webdriver
from time import sleep

from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from time import sleep

from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


from common.commin.commin import Move_scroll_bar

# from po.public_methods import yk_tt_ui_login

# driver=yk_tt_ui_login(mode=1)
# driver.implicitly_wait(10)
# driver.get('')
# driver.find_element(By.XPATH,"//div[@class='el-submenu__title']//span[contains(text(),'商品管理')]").click()
# driver.find_element(By.XPATH,"//li[@role='menuitem']//span[contains(text(),'管理商品')]").click()
# sleep(5)
# driver.find_element(By.XPATH,"//button[@class='el-button filter-item el-button--primary el-button--mini']").click()
# print(driver.get_window_rect())
# print(driver.get_window_size())
# driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
# sleep(10)
driver_com = webdriver.Chrome()
driver_com.implicitly_wait(10)
driver_com.get('http://testview.booseng.com/hwyd/#/login')
driver_com.maximize_window()
sleep(3)
driver_com.find_element(By.XPATH, '//*[@placeholder="账号"]').send_keys('admin')
driver_com.find_element(By.XPATH, '//*[@placeholder="密码"]').send_keys('huawang333.')
driver_com.find_element(By.XPATH, '//*[@placeholder="验证码"]').send_keys('123456')
driver_com.find_element(By.CSS_SELECTOR, '[class="el-button el-button--primary el-button--medium"]').click()
sleep(1)
print(driver_com.current_url)
driver_com.find_element(By.XPATH,"//div[@class='el-submenu__title']//span[contains(text(),'商品管理')]").click()


driver_com.find_element('xpath',"//span[contains(text(),'运费模板')]").click()
sleep(1)

first_text=driver_com.find_element('css selector','tr[class="el-table__row"]:nth-child(1)>td:nth-child(3)>div').get_attribute("textContent")
print(first_text)






# new_sel=driver_com.find_element('xpath','//div[@class="menu-wrapper"][3]/li')
# print("点击之前商品管理的属性",new_sel.get_attribute('class'))
# new_sel.click()
# sleep(2)
# print("点击之后商品管理的属性",new_sel.get_attribute('class'))

# driver_com.find_element(By.XPATH,"//li[@role='menuitem']//span[contains(text(),'管理商品')]").click()
# driver_com.find_element(By.XPATH,"//button[@type='button']//span[contains(text(),'新增')]").click()
# sleep(3)

# print('我的移动到了顶部')
# driver_com.execute_script("window.scrollTo(0,0);")
#
#
# print('我的移动到了最下面')
# driver_com.execute_script("window.scrollTo(0,2500);")
# # window.scrollTo(0, 0);
# # window.scrollTo(0, document.getElementById('elementId').offsetTop);
#
#
# sleep(2)
# print('我的移动到了3/5位置')
# Move_scroll_bar(driver_com,3,5)



#
# driver_com.execute_script('window.scrollBy(0,50)')





# # 创建一个ActionChains对象
# actions = ActionChains(driver_com)
#
# # 将鼠标移动到页面的顶部
# actions.move_to_element(driver_com.find_element_by_id("app"))
#
# # 向上滚动鼠标滚轮，滚动距离为当前滚动条顶部到目标位置的距离
# actions.perform()



# WebDriverWait(driver_com,timeout=15,poll_frequency=0.5).\
#     until(EC.visibility_of_element_located(('xpath',"//div[@id='pane-first']//input[@placeholder='输入搜索内容']"))).send_keys('auto_test商品')
#
#
# WebDriverWait(driver_com,timeout=15,poll_frequency=0.5).\
#     until(EC.visibility_of_element_located(('xpath',"//input[contains(@placeholder,'搜索类型')]"))).click()
#
# WebDriverWait(driver_com,timeout=15,poll_frequency=0.5).\
#     until(EC.presence_of_element_located(('css selector',"div[x-placement='bottom-start'] span"))).click()
#
# WebDriverWait(driver_com,timeout=15,poll_frequency=0.5).\
#     until(EC.presence_of_element_located(('xpath',"//div[@id='pane-first']//span[contains(text(),'搜索')]"))).click()
#
#
# results=WebDriverWait(driver_com,timeout=15,poll_frequency=0.5).\
#     until(EC.presence_of_element_located(('xpath',"//div[contains(text(),'auto_test商品001_20230829104953')]"))).text
#
# print(results)
# if results.startswith('auto_test商品001'):
# # if ret.text.startswith('半岛铁盒'):
#     print("测试通过")
# else:
#     print('测试失败')



# WebDriverWait(driver_com,timeout=15,poll_frequency=0.5).\
#     until(EC.element_to_be_clickable(('xpath',"//span[contains(text(),'搜索')]"))).click()

sleep(60)





